﻿using System;
using System.Text;
using System.Collections.Generic;
using System.Linq;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using EMANIFEST.Dtos;

namespace TestSaveRecord
{
    /// <summary>
    /// Summary description for TestShipStoreRecord
    /// </summary>
    [TestClass]
    public class TestShipStoreRecord
    {
        eManifestService.EmanifestServiceClient client = new eManifestService.EmanifestServiceClient();
        public TestShipStoreRecord()
        {
            //
            // TODO: Add constructor logic here
            //
        }

        private TestContext testContextInstance;

        /// <summary>
        ///Gets or sets the test context which provides
        ///information about and functionality for the current test run.
        ///</summary>
        public TestContext TestContext
        {
            get
            {
                return testContextInstance;
            }
            set
            {
                testContextInstance = value;
            }
        }

        #region Additional test attributes
        //
        // You can use the following additional attributes as you write your tests:
        //
        // Use ClassInitialize to run code before running the first test in the class
        // [ClassInitialize()]
        // public static void MyClassInitialize(TestContext testContext) { }
        //
        // Use ClassCleanup to run code after all tests in a class have run
        // [ClassCleanup()]
        // public static void MyClassCleanup() { }
        //
        // Use TestInitialize to run code before running each test 
        // [TestInitialize()]
        // public void MyTestInitialize() { }
        //
        // Use TestCleanup to run code after each test has run
        // [TestCleanup()]
        // public void MyTestCleanup() { }
        //
        #endregion

        [TestMethod]
        public void TestShipStore()
        {
            try
            {
                ShipStoreDeclarationDto shipdec = new ShipStoreDeclarationDto();
                shipdec.ShipStoreDeclarationId = new Guid("624F43BA-B1D8-4733-B200-0564C79B4988");
                shipdec.DocumentId = new Guid("DAB27624-2270-4C40-A977-8856C4A8388A");
                shipdec.PeriodOfStay = DateTime.Now;
                shipdec.PlaceOfStorage = "Bai kho cang update";
                shipdec.CreaterId = new Guid("93ec220c-5b57-4dac-88aa-9a314e1a7424");
                shipdec.CreatedDate = DateTime.Now;
                shipdec.ItemStatus = 0;
                shipdec.ModifyId = Guid.NewGuid();
                client.SaveShipStoreDeclarationRecord(shipdec);

                // kiem tra exists
               ShipStoreDeclarationDto ssdDto= client.GetShipStoreDeclarationById(shipdec.ShipStoreDeclarationId);
               if (ssdDto != null)
                   Console.WriteLine("Cap nhat thanh cong");
               else
                   Console.WriteLine("Cap nhat that bai");


            }
            catch(Exception ex)
            {
                Console.WriteLine(ex.InnerException.Message);
            }
        }

        [TestMethod]
        public void DeleteShipStore()
        {
            try
            {
                ResponseDto res = client.DeleteShipStoreDeclaration(new Guid("624F43BA-B1D8-4733-B200-0564C79B4988"));
                Console.WriteLine(res.IsSuccess);
            }
            catch(Exception ex)
            {
                Console.WriteLine(ex.InnerException.Message);
            }
        }
            

        [TestMethod]
        public void TestShipStoreItem()
        {
            try
            {
                ShipStoreItemDto ssItemdto = new ShipStoreItemDto();
                ssItemdto.ShipStoreItemId = new Guid("D16D82B1-7885-4CD0-8968-DBC81CAC2FA2");
                ssItemdto.Name = "ban khai du tru update";
                ssItemdto.Quantity = 100;
                ssItemdto.ShipStoreDeclarationId = new Guid("624F43BA-B1D8-4733-B200-0564C79B4988");
                client.SaveShipStoreItemRecord(ssItemdto);
            }
            catch(Exception ex)
            {
                Console.WriteLine(ex.InnerException.Message);
            }
        }


        [TestMethod]
        public void DeleteShipStoreItem()
        {
            try
            {
                ResponseDto res = client.DeleteShipStoreItem(new Guid("D16D82B1-7885-4CD0-8968-DBC81CAC2FA2"));
                Console.WriteLine(res.IsSuccess);
            }
            catch(Exception ex)
            {
                Console.WriteLine(ex.InnerException.Message);
            }
        }
    }
}
